package net.awpspace.mobile.management.note;

import javax.microedition.midlet.MIDlet;

import net.awpspace.mobile.form.BaseForm;

import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;

public class NoteManagement extends BaseForm {
	private static NoteManagement self;
	private Command addNote;
	public static String ADDNOTE = "Thêm note";
	private Command viewNotes;
	public static String VEWNOTES = "Xem tất cả note";
	private AudioManager audio = AudioManager.getInstance();

	public NoteManagement(final MIDlet app, BaseForm parent) {
		super(app, parent);
		self = this;
		setTitle("Quản lý Notes");
		setTransitionOutAnimator(CommonTransitions.createSlide(
				CommonTransitions.SLIDE_HORIZONTAL, true, 1200));
		addCommand();
		Container wapper = new Container(new BoxLayout(BoxLayout.Y_AXIS));

		Button add = new Button(ADDNOTE);
		add.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				audio.playSample("/button.mp3");
				new AddNote(app, getInstance()).show();
			}
		});
		Button view = new Button(VEWNOTES);
		view.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				audio.playSample("/button.mp3");
				new ViewNotes(app, getInstance()).show();
			}
		});

		wapper.addComponent(view);
		wapper.addComponent(add);

		wapper.addComponent(new Label(""));
		wapper.addComponent(new Label("Mobile Programing"));
		wapper.addComponent(new Label("Nguyễn Tuấn Hải"));
		wapper.addComponent(new Label("D09CNPM2"));

		this.addComponent(wapper);

	}

	public static NoteManagement getInstance() {
		return self;
	}

	protected void processCommand(ActionEvent e) {
		// TODO Auto-generated method stub
		if (e.getCommand().equals(addNote))
			new AddNote(app, this).show();
		else if (e.getCommand().equals(viewNotes))
			new ViewNotes(app, this).show();
	}

	private void addCommand() {
		addNote = new Command(ADDNOTE, 1);
		addCommand(addNote);
		viewNotes = new Command(VEWNOTES, 2);
		addCommand(viewNotes);
	}

}
